package com.didispace.web;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

@RestController
public class ConsumerController {

    @Autowired
    HelloService helloService;
    RestTemplate restTemplate;

    @RequestMapping(value = "/ribbon-consumer", method = RequestMethod.GET)
    public String helloConsumer() {
        return helloService.hello();
        // return restTemplate.getForEntity("http://HELLO-SERVICE/hello", String.class).getBody();
    }

}

// 2022-04-29 16:59:44.147  INFO 20012 --- [nfoReplicator-0] com.netflix.discovery.DiscoveryClient    : DiscoveryClient_RIBBON-CONSUMER/localhost:ribbon-consumer:9000 - registration status: 204

// http://localhost:9000/ribbon-consumer
// Hello World

// 2022-04-29 17:00:29.924  INFO 20012 --- [nio-9000-exec-1] c.n.l.DynamicServerListLoadBalancer      : DynamicServerListLoadBalancer for client HELLO-SERVICE initialized: DynamicServerListLoadBalancer:{NFLoadBalancer:name=HELLO-SERVICE,current list of Servers=[localhost:8081],Load balancer stats=Zone stats: {defaultzone=[Zone:defaultzone;	Instance count:1;	Active connections count: 0;	Circuit breaker tripped count: 0;	Active connections per server: 0.0;]
// },Server stats: [[Server:localhost:8081;	Zone:defaultZone;	Total Requests:0;	Successive connection failure:0;	Total blackout seconds:0;	Last connection made:Thu Jan 01 08:00:00 CST 1970;	First connection made: Thu Jan 01 08:00:00 CST 1970;	Active Connections:0;	total failure count in last (1000) msecs:0;	average resp time:0.0;	90 percentile resp time:0.0;	95 percentile resp time:0.0;	min resp time:0.0;	max resp time:0.0;	stddev resp time:0.0]
// ]}ServerList:org.springframework.cloud.netflix.ribbon.eureka.DomainExtractingServerList@2c6f6bbc
// 2022-04-29 17:00:30.914  INFO 20012 --- [erListUpdater-0] c.netflix.config.ChainedDynamicProperty  : Flipping property: HELLO-SERVICE.ribbon.ActiveConnectionsLimit to use NEXT property: niws.loadbalancer.availabilityFilteringRule.activeConnectionsLimit = 2147483647
